﻿<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.crm.util.RequestEx"%>
<%@ page import="com.crm.service.InventoryPpService"%>
<%@ page import="com.crm.service.ConfigService"%>
<%@ page import="com.crm.po.Config"%>
<%@ page import="com.crm.util.SESSION"%>
<%@ page import="com.crm.po.Users"%>
<%
	Object obj = request.getSession(true).getAttribute(SESSION.USER_SESSION_KEY);
	Users users = null;
	if(obj != null){
		users = (Users) obj;
	}
	String path = request.getContextPath();
	String treeid = RequestEx.getStringTrim(request.getParameter("treeid"));
	InventoryPpService service = new InventoryPpService();
	
	Config systemConfig = service.getConfigTaxrate("taxrate");
	String taxrate = systemConfig.getCValue();
	int invppCount = service.getInventoryPpsCountByTreeid(treeid, "Y");
	
	ConfigService configService = new ConfigService();
	Config unitsConfig = configService.getConfigByKey("units");
	String units = unitsConfig.getCValue();
	String[] unitsArray = null;
	if(units.length() > 0){
		unitsArray = units.split("_");
	}

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>  
    <title>CRM</title>
    <link rel="icon" mce_href="<%=path%>/images/title_logo.ico" href="<%=path%>/images/title_logo.ico" type="image/x-ico"/>
    <link rel="shortcut icon" mce_href="<%=path%>/images/title_logo.ico" href="<%=path%>/images/title_logo.ico" type="image/x-ico"/>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>	
	<link rel="stylesheet" type="text/css" href="<%=path%>/js/easyui1.3.2/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/js/easyui1.3.2/themes/icon.css">	
	<script type="text/javascript" src="<%=path%>/js/easyui1.3.2/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/easyui1.3.2/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/easyui1.3.2/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="<%=path%>/js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="<%=path%>/js/math.js"></script>
	<style type="text/css">
		body,td,th,div{
 			font-size:12px;
		}
	</style>
  </head>
  
  <body style="margin:0;padding:0" class="easyui-layout">
    <script type="text/javascript">

	var datagrid;
	var url = "<%=path%>/invpp.do";

	//准备新增数据
	function readySave(){
		document.getElementById("saveAndGoon").style.display="inline";
		$('#invppSaveOrUpdate').dialog({  
			title: '新增',  
			width: 768,
			height: 285,
			closed: false,  
			cache: false,   
			modal: true,
			onClose:function(){$('#invppSaveOrUpdateForm').form('clear');}
		});
	}
	//新增数据
	function doSave(isContinue){		
		$("#invppSaveOrUpdateForm").form('submit', { 
	        url: url + '?method=saveOrUpdateInventoryPp&treeid=<%=treeid%>',	        
			success:function(data){
				if('ok' == data){
					if(isContinue){
						//$('#invppSaveOrUpdateForm').form('clear');
					}else{
						$('#invppSaveOrUpdate').dialog('close');
					}					
					datagrid.datagrid('reload');
				}else{
					$.messager.alert('提示', data, 'info');
				}
			},
			error : function() {
			
			}
		});
	}

	//修改数据
	function doUpdate(){
		var node = datagrid.datagrid('getSelected');
		document.getElementById("saveAndGoon").style.display="none";
		$('#invppSaveOrUpdate').dialog({  
			title: '修改',  
			width: 768,
			height: 285,
			closed: false,  
			cache: false,   
			modal: true,
			onClose:function(){$('#invppSaveOrUpdateForm').form('clear');}
		});
		$('#invppSaveOrUpdateForm').form('load',{
			insid: node.insid,
			institution: node.institution,			
			senddate: node.senddate,
			goods: node.goods,
			amount: node.amount,
			unit: node.unit,
			price0: node.price0,
			totalprice0: node.totalprice0,
			price1: node.price1,
			totalprice1: node.totalprice1,
			grossprofit: node.grossprofit,
			purchaser: node.purchaser,
			ordernumber: node.ordernumber,
			user: node.user,
			supplier: node.supplier,
			linkman: node.linkman,
			tel: node.tel,
			phone: node.phone,
			email: node.email,
			address: node.address,
			remark: node.remark,
			sort: node.sort
		});	
	}

	//删除数据
	function doDelete(){
		var node = datagrid.datagrid('getSelected');
		//删除确认
		$.messager.confirm('提示','<br>您确定删除选中的数据吗?',function(r){ 
			if(r){ 
				//执行删除
				var insids = "'" + node.insid + "'";

				$.ajax({
					url : url + '?method=deleteInventoryPp&treeid=<%=treeid%>',
					type : 'POST',
					data : {insids : insids},
					success : function(data, textStatus) {
						if('ok' == data){
							datagrid.datagrid('load');
						}else{								
							$.messager.alert('提示', data, 'info');
						}		
					}
				});
			} 
		});
	}
	//查询
	function doQuery(){
		datagrid.datagrid('options').url = url+'?method=getInventoryPpList&treeid=<%=treeid%>&islive=Y';
		var queryParams = datagrid.datagrid('options').queryParams;
		
		if($.trim($("#goods").val()).length == 0 && 
		   $.trim($("#ordernumber").val()).length == 0 && 
		   $.trim($("#supplier").val()).length == 0 && 
		   $.trim($("#linkman").val()).length == 0 && 
		   $.trim($('#fromDate').val()).length == 0 && 
		   $.trim($('#toDate').val()).length == 0){
			   
		   	queryParams.goods = "";
		   	queryParams.ordernumber = "";
		   	queryParams.supplier = "";
		   	queryParams.linkman = "";
		   	queryParams.fromDate = "";
		   	queryParams.toDate = "";
		}else{
			queryParams.goods = $("#goods").val();
			queryParams.ordernumber = $("#ordernumber").val();
			queryParams.supplier = $("#supplier").val();
			queryParams.linkman = $("#linkman").val();
			queryParams.fromDate = $('#fromDate').val();
			queryParams.toDate = $('#toDate').val();
		}
		datagrid.datagrid('load');
	}
	
	//定义datagrid列模型
	var columns = [[
		{field:'ck',checkbox:true},        	
		{field:'oper',title:'操作',width:70,formatter:formatOper},
		{field:'insid',title:'采购主键',width:20,hidden:true},
		{field:'institution',title:'公司名称',width:100,hidden:true},
		{field:'senddate',title:'送货日期',width:80,sortable:true},
		{field:'goods',title:'采购物品',width:220,sortable:true},
		{field:'amount',title:'数量',width:50,sortable:true},
		{field:'unit',title:'单位',width:50,sortable:true},
		
		{field:'price0',title:'采购单价',width:80,formatter:formatPrice,sortable:true},
		{field:'totalprice0',title:'采购合计金额',width:80,formatter:formatPrice,sortable:true},
		{field:'price1',title:'销售单价',width:80,formatter:formatPrice,sortable:true},
		{field:'totalprice1',title:'销售合计金额',width:80,formatter:formatPrice,sortable:true},
		
		{field:'grossprofit',title:'毛利润',width:80,formatter:formatPrice,sortable:true},
		{field:'purchaser',title:'购货人',width:60,sortable:true},
		{field:'ordernumber',title:'订单号',width:80,sortable:true},
		
		{field:'email',title:'客户采购',width:120,sortable:true},
		
		{field:'user',title:'使用人',width:60,sortable:true},
		{field:'supplier',title:'供应商',width:180,sortable:true},
		{field:'linkman',title:'联系人',width:80,sortable:true},
		{field:'tel',title:'固定电话',width:120,sortable:true},
		{field:'phone',title:'移动电话',width:120,sortable:true,hidden:true},
		{field:'address',title:'地址',width:120,sortable:true,hidden:true},
		{field:'remark',title:'备注',width:150},
		{field:'creater',title:'创建用户',width:100},
		{field:'updater',title:'最后修改用户',width:100},
		{field:'creattime',title:'创建时间',width:115,formatter:formatDate},
		{field:'updatetime',title:'最后修改时间',width:115,formatter:formatDate},		
		{field:'sort',title:'排序',width:30,sortable:true}
	]];

	//入口
	$(function(){
		datagrid = $('#datagrid');
		$(datagrid).datagrid({
			url:url+'?method=getInventoryPpList&treeid=<%=treeid%>&islive=Y', 
			toolbar:'#tb',
			columns:columns,
			title:'', 
			loadMsg:'正在处理...',
			iconCls:'', 
			nowrap: true, 
			selectOnCheck: false,
			checkOnSelect: false,
			rownumbers: true,
			remoteSort: false,
			autoRowHeight: false,
			autoRowWidth: true,             
			animate:true, 
			singleSelect: true,
			collapsible: true, 
			fitColumns: false,//自动充满列
			fit:true,//自动充满浏览器区域
			idField:'insid', 
			showFooter: false,
			striped:true,//斑马线
			pagination:true,
			pageSize:50,
			onClickRow:function(rowIndex, rowData){
				viewDetails(rowData);
			},
			onDblClickRow:function(rowIndex, rowData){
				<%
				if(users.getInvppAuth().indexOf("AUTH_U") >= 0){
				%>
				doUpdate();
				<%	
				}
				%>				
			},
			onLoadSuccess:function(data){
				var p = datagrid.datagrid('getPager');  
				$(p).pagination({
					buttons : [
								<%if(users.getInvppAuth().indexOf("AUTH_J") >= 0){%>
								   {
									text:'计算合计',
									handler:function(){
										sumDatagrid();
									}
								   }
								<%}if(users.getInvppAuth().indexOf("AUTH_J") >= 0 && users.getInvppAuth().indexOf("AUTH_E") >= 0){%>
								   ,
								<%}if(users.getInvppAuth().indexOf("AUTH_E") >= 0){%>
								   {
									text:'导出',
									handler:function(){
										readyExport();
									}
								   }
								<%}%>
								   ],
					pageList:[50, 100, 200, 500, <%=invppCount <= 500 ? "1000" : invppCount + ""%>]
			    });  
			}
		}); 
	}); 

	function readyUpdateDdnumber(){
		var checkedItems = datagrid.datagrid('getChecked');
		if(checkedItems.length == 0){
			$.messager.alert('提示', '<br>请选择至少一条数据。', 'info');
			return;
		}
		var insids = "";

		$.each(checkedItems, function(index, item){
			if(insids.length > 0){insids = insids + ",";}
			insids = insids + "'" + item.insid + "'";
		});
		document.getElementById("insids").value = insids;
		document.getElementById("ddnumberTotal").innerHTML = checkedItems.length;
		$('#updateDdnumber').dialog({  
			title: '新增',  
			width: 300,
			height: 170,
			closed: false,  
			cache: false,   
			modal: true,
			onClose:function(){$('#updateDdnumberForm').form('clear');}
		});
	}

	function doUpdateDdnumber(){
		$("#updateDdnumberForm").form('submit', { 
	        url: url + '?method=updateDdnumber&treeid=<%=treeid%>',	        
			success:function(data){
				if('ok' == data){
					$('#updateDdnumber').dialog('close');					
					datagrid.datagrid('reload');
				}else{
					$.messager.alert('提示', data, 'info');
				}
			},
			error : function() {
			
			}
		});
	}
	
	function sumDatagrid(){
		var checkedItems = datagrid.datagrid('getChecked');

		var amount_sum = '';
		var price0_sum = '';
		var totalprice0_sum = '';
		var price1_sum = '';
		var totalprice1_sum = '';
		var grossprofit_sum = '';
		$.each(checkedItems, function(index, item){
			if(amount_sum.length > 0){amount_sum = amount_sum + '_';}
			if(price0_sum.length > 0){price0_sum = price0_sum + '_';}
			if(totalprice0_sum.length > 0){totalprice0_sum = totalprice0_sum + '_';}
			if(price1_sum.length > 0){price1_sum = price1_sum + '_';}
			if(totalprice1_sum.length > 0){totalprice1_sum = totalprice1_sum + '_';}
			if(grossprofit_sum.length > 0){grossprofit_sum = grossprofit_sum + '_';}
			
			amount_sum = amount_sum + item.amount;
			price0_sum = price0_sum + item.price0;
			totalprice0_sum = totalprice0_sum + item.totalprice0;
			price1_sum = price1_sum + item.price1;
			totalprice1_sum = totalprice1_sum + item.totalprice1;
			grossprofit_sum = grossprofit_sum + item.grossprofit;
		});

		$.ajax({
			url : url + '?method=mathBatchAdd',
			type : 'POST',
			data : {amount_temp : amount_sum,
					price0_temp : price0_sum,
					totalprice0_temp : totalprice0_sum,
					price1_temp : price1_sum,
					totalprice1_temp : totalprice1_sum,
					grossprofit_temp : grossprofit_sum},
			success : function(data, textStatus) {
					amount_sum = data.amount_sum;
					price0_sum = formatPrice(data.price0_sum, null);
					totalprice0_sum = formatPrice(data.totalprice0_sum, null);
					price1_sum = formatPrice(data.price1_sum, null);
					totalprice1_sum = formatPrice(data.totalprice1_sum, null);
					grossprofit_sum = formatPrice(data.grossprofit_sum, null);

					amount_sum = "数量：<span style='font-weight:bold;color:#FF0000;font-size:14px'>" + amount_sum + "</span><span style='color:#FFFFFF;'>__</span>";
					price0_sum = "采购单价：<span style='font-weight:bold;color:#FF0000;font-size:14px'>" + price0_sum + "</span><span style='color:#FFFFFF;'>__</span>";
					totalprice0_sum = "采购合计金额：<span style='font-weight:bold;color:#FF0000;font-size:14px'>" + totalprice0_sum + "</span><span style='color:#FFFFFF;'>__</span>";
					price1_sum = "销售单价：<span style='font-weight:bold;color:#FF0000;font-size:14px'>" + price1_sum + "</span><span style='color:#FFFFFF;'>__</span>";
					totalprice1_sum = "销售合计金额：<span style='font-weight:bold;color:#FF0000;font-size:14px'>" + totalprice1_sum + "</span><span style='color:#FFFFFF;'>__</span>";
					grossprofit_sum = "毛利润：<span style='font-weight:bold;color:#FF0000;font-size:14px'>" + grossprofit_sum + "</span><span style='color:#FFFFFF;'>__</span>";

					document.getElementById("sumDatagrid").innerHTML = amount_sum + price0_sum + totalprice0_sum + price1_sum + totalprice1_sum + grossprofit_sum;
			}
		});
	}
	
	//预览文件数据图片
	function viewDetails(row){
		document.getElementById("supplierView").innerText = row.supplier;
		document.getElementById("linkmanView").innerText = row.linkman;	
		document.getElementById("addressView").innerText = row.address;
		document.getElementById("remarkView").innerText = row.remark;
	}

	//格式化创建时间
	function formatDate(value, row){
		value = value + '';
		if(value == null || value.length == 0){
			return "";
		}
		var yy = '';
		var mo = '';
		var da = '';
		
		var ho = '';
		var mm = '';
		var ss = '';

		var dateTime = '';
		if(value.length > 4){
			yy = value.substr(0, 4);
			dateTime = dateTime + yy;
		}
		if(value.length > 6){
			mo = value.substr(4, 2);
			dateTime = dateTime + '-' + mo;
		}
		if(value.length > 8){
			da = value.substr(6, 2);
			dateTime = dateTime + '-' + da;
		}
		
		if(value.length > 10){
			ho = value.substr(8, 2);
			dateTime = dateTime + ' ' + ho;
		}
		if(value.length > 12){
			mm = value.substr(10, 2);
			dateTime = dateTime + ':' + mm;
		}
		if(value.length >= 14){
			ss = value.substr(12, 2);
			dateTime = dateTime + ':' + ss;
		}
		return dateTime;
	}

	//格式化操作
	function formatOper(value, row){
		var updateOper = "<font color='#C0C0C0'>修改</font>";
		var deleteOper = "<font color='#C0C0C0'>删除</font>";
		<%
		if(users.getInvppAuth().indexOf("AUTH_U") >= 0){
		%>
			updateOper = "<a href='javascript:doUpdate();'>修改</a>";
		<%
		}
		if(users.getInvppAuth().indexOf("AUTH_D") >= 0){
		%>
			deleteOper = "<a href='javascript:doDelete();'>删除</a>";
		<%
		}
		%>
		return updateOper + '&nbsp;&nbsp;&nbsp;' + deleteOper + '&nbsp;&nbsp;&nbsp;';
	}

	//格式化价格
	function formatPrice(value, row){
		var tempValue = value + '';
		if(tempValue.indexOf(".") > 0){
			var arr = tempValue.split(".");
			if(arr[1].length == 1){
				tempValue = tempValue + "0";
			}else if(arr[1].length > 2){
				tempValue = arr[0] + '.' + arr[1].substr(0, 2);
			}
		}else{
			tempValue = tempValue + ".00";
		}
		return tempValue;
	}

	//准备导出数据
	function readyExport(){
		$('#invppExport').dialog({  
			title: '导出数据到Excel',  
			width: 200,
			height: 180,
			closed: false,  
			cache: false,   
			modal: true
		});
	}

	function exeExport(){
		var exportType = $("input[name='exportType']:checked").val() 
		
		var insids = '';
		var goods = '';
		var ordernumber = '';
		var supplier = '';
		var linkman = '';
		var fromDate = '';
		var toDat = '';
		
		if(exportType == 1){
			var checkedItems = datagrid.datagrid('getChecked');
			if(checkedItems.length == 0){
				$.messager.alert('提示', '<br>您没有选中任何数据。', 'info');
				return;
			}
			$.each(checkedItems, function(index, item){
				if(insids.length > 0){insids = insids + ',';}
				insids = insids + "'" + item.insid + "'";
			});
		}else if(exportType == 2){	
			var rowsItems = datagrid.datagrid('getRows');
			if(rowsItems.length == 0){
				$.messager.alert('提示', '<br>当前页没有任何数据。', 'info');
				return;
			}
			$.each(rowsItems, function(index, row){
				if(insids.length > 0){insids = insids + ',';}
				insids = insids + "'" +row.insid + "'";
			});
		}else if(exportType == 3){
			var queryParams = datagrid.datagrid('options').queryParams;
			goods = queryParams.goods;
			ordernumber = queryParams.ordernumber;
			supplier = queryParams.supplier;
			linkman = queryParams.linkman;
			fromDate = queryParams.fromDate;
			toDat = queryParams.toDate;
		}else{
			$.messager.alert('提示', '<br>请选择导出Excel方式。', 'info');
			return;
		}

	    var form = $('<form></form>');  
	    // 设置属性  
	    form.attr('action', url + '?method=exportInventoryPpExcel&treeid=<%=treeid%>&islive=Y');  
	    form.attr('method', 'post');  
	    form.attr('target', '_self');  
	    // 创建Input  
	    var insidsInput = $('<input type="text" name="insids"/>');  
	    insidsInput.attr('value', insids);  
	    var goodsInput = $('<input type="text" name="goods"/>');  
	    goodsInput.attr('value', goods);  
	    var ordernumberInput = $('<input type="text" name="ordernumber"/>');  
	    ordernumberInput.attr('value', ordernumber);  
	    var supplierInput = $('<input type="text" name="supplier"/>');  
	    supplierInput.attr('value', supplier);  
	    var linkmanInput = $('<input type="text" name="linkman"/>');  
	    linkmanInput.attr('value', linkman);  
	    var fromDateInput = $('<input type="text" name="fromDate"/>');  
	    fromDateInput.attr('value', fromDate);  
	    var toDatInput = $('<input type="text" name="toDat"/>');  
	    toDatInput.attr('value', toDat);  

	    form.append(insidsInput);  
	    form.append(goodsInput);  
	    form.append(ordernumberInput);  
	    form.append(supplierInput);  
	    form.append(linkmanInput);  
	    form.append(fromDateInput);  
	    form.append(toDatInput); 

	    form.appendTo("body") 

	    form.submit();  
	}
	</script>

	<div data-options="region:'center',title:'普票客户管理'">
	
	<!-- 表格面板 -->
	<table id="datagrid"></table>
	
	<!-- 新增或编辑面板 -->
	<div id="invppSaveOrUpdate" class="easyui-dialog" closed="true" data-options="buttons:'#buttonsSaveOrUpdate'" style="padding-top:10px;overflow:hidden">
	    <form id="invppSaveOrUpdateForm" name="invppSaveOrUpdateForm" action="" method="post">
	    	<input type="hidden" id="insid" name="insid" value="">
	    	<table border="0" bordercolor="red">
				<tr height="30px">
	    			<!--  
	    			<td width="80px" align="right">公司名称</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="institution" name="institution" data-options="validType:['length[0,200]']"/></td>
	    			-->
	    			<td width="80px" align="right">采购物品</td>
	    			<td colspan="3"><input style="width:100%" class="easyui-validatebox" type="text" id="goods" name="goods" data-options="validType:['length[0,200]']"/></td>
	    			<td width="80px" align="right">送货日期</td>
	    			<td><input id="senddate" name="senddate" class="Wdate" type="text" style="width:160px;height:21px" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,isShowClear:true})"/></td>
	    			    
	    		</tr>
	    		<tr height="30px">
	    			<td width="80px" align="right">购货人</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="purchaser" name="purchaser" data-options="validType:['length[0,20]']"/></td>
	    			<td width="80px" align="right">使用人</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="user" name="user" data-options="validType:['length[0,20]']"/></td>
	    			<td width="80px" align="right">订单号</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="ordernumber" name="ordernumber" data-options="validType:['length[0,50]']"/></td>
	    		</tr>
	    		<!--
	    		<tr height="30px">
	    			<td width="80px" align="right">供应商</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="supplier" name="supplier" data-options="validType:['length[0,200]']"/></td>
	    			<td width="80px" align="right">联系人</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="linkman" name="linkman" data-options="validType:['length[0,20]']"/></td>
	    			<td width="80px" align="right">单位</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="unit" name="unit" data-options="validType:['length[0,20]']"/></td>
	    		</tr>
	    		-->
	    		<tr height="30px">
	    			<td width="80px" align="right">数量</td>
	    			<td>
	    				<input onBlur="javascript:toJSForPp()" style="width:100px" class="easyui-numberbox" type="text" id="amount" name="amount" data-options="precision:2,min:0.00,max:9999999999.99" value="0.00"/>
	    				<select id="unit" name="unit" style="width:56px;height:21px;">
	    					<%if(unitsArray.length > 0){
	    						for(String unit : unitsArray){
	    						%>
	    						<option value="<%=unit%>"><%=unit%></option>
	    						<%	
	    						}
	    					}%>
	    				</select>	
	    			</td>
	    			<td align="right">采购单价</td>
	    			<td><input onBlur="javascript:toJSForPp()" style="width:160px" class="easyui-numberbox" type="text" id="price0" name="price0" data-options="precision:2,min:0.00,max:9999999999.99" value="0.00"/></td>
	    			<td align="right">采购合计金额</td>
	    			<td><input style="width:160px;background-color:#C0C0C0" class="easyui-validatebox" readOnly type="text" id="totalprice0" name="totalprice0" data-options="" value="0.00"/></td>
	    		</tr>
	    		<tr height="30px">
	    			<td width="80px" align="right">毛利润</td>
	    			<td><input style="width:160px;background-color:#C0C0C0" class="easyui-validatebox" readOnly type="text" id="grossprofit" name="grossprofit" data-options="" value="0.00"/></td>
	    			<td align="right">销售单价</td>
	    			<td><input onBlur="javascript:toJSForPp()" style="width:160px" class="easyui-numberbox" type="text" id="price1" name="price1" data-options="precision:2,min:0.00,max:9999999999.99" value="0.00"/></td>
	    			<td align="right">销售合计金额</td>
	    			<td><input style="width:160px;background-color:#C0C0C0" class="easyui-validatebox" readOnly type="text" id="totalprice1" name="totalprice1" data-options="" value="0.00"/></td>
	    		</tr>
	    		<tr height="30px">
	    			<td width="80px" align="right">供应商</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="supplier" name="supplier" data-options="validType:['length[0,200]']"/></td>
	    			<td width="80px" align="right">联系人</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="linkman" name="linkman" data-options="validType:['length[0,20]']"/></td>
	    			<td width="80px" align="right">固定电话</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="tel" name="tel" data-options="validType:['length[0,600]']"/></td>
	    		</tr>
	    		<tr height="30px">
	    			
	    			<td width="80px" align="right">客户采购</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="email" name="email" data-options="validType:['length[0,200]']"/></td>
	    			
	    			<!--  
	    			<td align="right">排序</td>
	    			<td><input style="width:160px" class="easyui-numberbox" type="text" id="sort" name="sort" data-options="validType:['length[0,6]']" value="0"/></td>
	    			-->
	    			<td align="right">备注</td>
	    			<td colspan="3"><input style="width:100%" class="easyui-validatebox" type="text" id="remark" name="remark" data-options="validType:['length[0,2000]']"/></td>
	    		</tr>
	    	</table>
	    </form>
	</div>
	<div id="buttonsSaveOrUpdate" style="display:none">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:doSave(false)">保存</a>
		<span id="saveAndGoon">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:doSave(true)">保存并继续新增</a>
		</span>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#invppSaveOrUpdate').dialog('close');">关闭</a>
	</div>
	
	<!-- 修改订单号面板 -->
	<div id="updateDdnumber" class="easyui-dialog" closed="true" data-options="buttons:'#buttonsUpdateDdnumber'" style="padding-top:10px;overflow:hidden">
	    <form id="updateDdnumberForm" name="updateDdnumberForm" action="" method="post">
	    	<input width="500px" type="hidden" id="insids" name="insids" value="">
	    	<table border="0" bordercolor="red">
				<tr height="30px">
	    			<td width="80px" align="right">&nbsp;</td>
	    			<td>您共选择了&nbsp;<span id="ddnumberTotal" style='font-weight:bold;color:#FF0000;'></span>&nbsp;条数据</td>
	    		</tr>
				<tr height="30px">
	    			<td width="80px" align="right">新订单号</td>
	    			<td><input style="width:160px" class="easyui-validatebox" type="text" id="newDdnumber" name="newDdnumber" data-options="required:true,validType:['length[0,200]']"/></td>
	    		</tr>
	    	</table>
	    </form>
	</div>
	<div id="buttonsUpdateDdnumber" style="display:none">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:doUpdateDdnumber()">保存</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#updateDdnumber').dialog('close');">关闭</a>
	</div>	
	
	<!-- 导出面板 -->
	<div id="invppExport" class="easyui-dialog" closed="true" data-options="buttons:'#buttonsInvppExport'" style="padding-top:10px;overflow:hidden">
	    	<table border="0" bordercolor="red">
				<tr height="25px">
	    			<td style="padding-left:20px"><input type="radio" id="" name="exportType" value="1"/></td><td style="padding-left:5px">导出选中数据</td>
	    		</tr>
	    		<tr height="25px">
	    			<td style="padding-left:20px"><input type="radio" id="" name="exportType" value="2"/></td><td style="padding-left:5px">导出当前页数据</td>
	    		</tr>
	    		<tr height="25px">
	    			<td style="padding-left:20px"><input type="radio" id="" name="exportType" value="3"/></td><td style="padding-left:5px">导出所有数据</td>
	    		</tr>
	    	</table>
	</div>
	<div id="buttonsInvppExport" style="display:none">
		<a href="javascript:exeExport();" class="easyui-linkbutton">导出</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#invppExport').dialog('close');">取消</a>
	</div>
	
	<!-- 增，删，改，查面板 -->
	<div id="tb" style="padding:0px;height:auto">
		<table width="100%" border="0" bordercolor="red">
			<tr>
				<td style="padding-right:0px">
					<%if(users.getInvppAuth().indexOf("AUTH_A") >= 0){
					%>
					<a href="javascript:readySave();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">新增</a>
					<%
					}else{
					%>
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'" style="color:#C0C0C0">新增</a>
					<%	
					}
					if(users.getInvppAuth().indexOf("AUTH_U") >= 0){
					%>
					<a href="javascript:readyUpdateDdnumber();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">修改订单号</a>
					<%
					}else{
					%>
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'" style="color:#C0C0C0">修改订单号</a>
					<%	
					}%>
				</td>
				<td>采购物品</td>
				<td><input id="goods" name="goods" class="easyui-validatebox" style="width:80px;height:20px"/></td>			
				<td style="padding-left:0px">订单号</td>
				<td><input id="ordernumber" name="ordernumber" class="easyui-validatebox" style="width:80px;height:20px"/></td>
				<td style="padding-left:0px">供应商</td>
				<td><input id="supplier" name="supplier" class="easyui-validatebox" style="width:80px;height:20px"/></td>
				<td style="padding-left:0px">联系人</td>
				<td><input id="linkman" name="linkman" class="easyui-validatebox" style="width:80px;height:20px"/></td>
				
				<td>送货日期</td>
				<td>				
					<input id="fromDate" name="fromDate" class="Wdate" type="text" style="width:90px;height:20px" onFocus="var toDate=$dp.$('toDate');WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,isShowClear:true,onpicked:function(){toDate.focus();},maxDate:'#F{$dp.$D(\'toDate\')}'})"/>	
				</td>
				<td align="center">至</td>
				<td>				
					<input id="toDate" name="toDate" class="Wdate" type="text" style="width:90px;height:20px" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,isShowClear:true,minDate:'#F{$dp.$D(\'fromDate\')}'})"/>	
				</td>
				<td style="padding-left:0px">
					<a href="javascript:doQuery();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'">查询</a>
				</td>								
			</tr>
		</table>
	</div>
	
	
	</div>
	<!-- 详细信息面板 -->
	<div data-options="region:'south',border:false" style="height:110px;background:#D8D8D8;padding:0px;">
		<table width="100%" border="0" bordercolor="red">
			<tr height="25px">
				<td bgcolor="#CCDDFF" align="right">合计：</td>
				<td colspan="3" bgcolor="#F8F8F8"><span id="sumDatagrid"></span></td>				
			</tr>
			<tr height="25px">
				<td width="9%" align="right" bgcolor="#CCDDFF">供应商：</td><td width="41%" bgcolor="#F8F8F8"><span id="supplierView"></span></td>
				<td width="9%" align="right" bgcolor="#CCDDFF">联系人：</td><td width="41%" bgcolor="#F8F8F8"><span id="linkmanView"></span></td>
			</tr>
			<tr height="25px">
				<td bgcolor="#CCDDFF" align="right">地址：</td><td colspan="3" bgcolor="#F8F8F8"><span id="addressView"></span></td>
			</tr>
			<tr height="25px">
				<td bgcolor="#CCDDFF" align="right">备注：</td><td colspan="3" bgcolor="#F8F8F8"><span id="remarkView"></span></td>
			</tr>
		</table>
	</div>
  </body>
</html>
